from django.db import models
from course.models import Course
from student.models import Student
# Create your models here.
class Record(models.Model):
    # 序号
    id = models.AutoField('序号',primary_key=True)
    # 学生id
    student_id = models.ForeignKey(Student,on_delete=models.CASCADE,verbose_name='学号',related_name='stu_sno')
    # 课程名称
    course = models.ForeignKey(Course,on_delete=models.CASCADE,verbose_name='课程名称',related_name='stu_course')
    # 成绩
    grade = models.FloatField(verbose_name='成绩')
    # 创建时间，增加时自动添加
    create_time = models.DateField(verbose_name='创建时间', auto_now_add=True, null=True)
    # 修改时间，修改时自动添加
    modify_time = models.DateField(verbose_name='修改时间', auto_now=True, null=True)
    # 是否删除
    is_delete = models.BooleanField(verbose_name='是否删除', default=False, null=True)

    class Meta:
        verbose_name = '学生成绩'
        verbose_name_plural = '学生成绩'

    def __str__(self):
        return '<%s:%s>' % (self.student_id,self.grade)